<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>用户注册</title>

</head>
<body>
<!--这是一段注释。extends继承basepage.html页面-->
{% extends "Photography/basepage.html" %}
{% block content %}

    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
    <script>
        $(document).ready(function () {
            $('#button').click(function () {
                var name = $("#id_username").val();
                var psw = $("#id_password").val();
                var email = $("#id_email").val();
                var token = $('[name="csrfmiddlewaretoken"]').attr("value");
                if (name && psw) {
                    $.post("/api/v1/users/",
                        {
                            "username": name,
                            "password": psw,
                            "email": email,
                            "csrfmiddlewaretoken": token
                        },
                        function (result) {
                            if (result.code == "100") {
                                window.location.href = "/login";   //页面成功跳转
                            } else {
                                $("#msg").text(result.msg)          //页面失败显示提示语
                            }

                        });
                } else {
                    $("#msg").text("账号或密码不对！")
                }

            });
        })
    </script>
    <div style="margin: 5% 40%;">
        <h1>用户注册页面 </h1>
        <form>
            {% csrf_token %}
            <p>用户名:<input type="text" id="id_username" name="username" value="" required="required"
                          placeholder="请输入用户名">
                * {{ rename }}    </p>
            <p>密码:<input type="password" id="id_password" name="password" value="" required="required"
                         placeholder="请输入密码">*
            </p>
            <p>邮箱:<input type="text" id="id_email" name="email" value="" required="required" placeholder="请输入邮箱">*</p>
            <p style="color:red" id="msg">
                {{ msg }}        </p>


        </form>

        <br>
        忘记密码？<a href="{% url 'Photography:reset' %}">点击修改！</a>
        <br>
        <input type="submit" id="button" value="提交">
    </div>
{% endblock content %}
</body>
</html>